package org.asiainfo.audit.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import org.asiainfo.common.mybatis.core.page.PageQuery;
import org.asiainfo.common.mybatis.core.page.TableDataInfo;
import org.springframework.validation.annotation.Validated;
import org.asiainfo.audit.service.TbAuditMessageService;
import org.asiainfo.audit.domain.vo.TbAuditMessageVo;
import org.asiainfo.audit.domain.bo.TbAuditMessageBo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.asiainfo.common.core.domain.R;
import org.asiainfo.common.web.core.BaseController;
import jakarta.validation.constraints.*;

/**
 * 审计信息
 *
 * @author dotor-ww
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/message")
public class TbAuditMessageController extends BaseController {

    private final TbAuditMessageService tbAuditMessageService;

    /**
     * 分页查询
     *
     * @param tbAuditMessageBo 筛选条件
     * @param pageQuery        分页对象
     * @return 查询结果
     */
    @SaCheckPermission("audit:message:list")
    @GetMapping("/list")
    public TableDataInfo<TbAuditMessageVo> list(TbAuditMessageBo tbAuditMessageBo, PageQuery pageQuery) {
        return tbAuditMessageService.queryPageList(tbAuditMessageBo, pageQuery);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @SaCheckPermission("audit:message:query")
    @GetMapping("/{id}")
    public R<TbAuditMessageVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable("id") Long id) {
        return R.ok(tbAuditMessageService.queryById(id));
    }
}

